﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace Zen4SyncDashboard.Converter
{
    [ValueConversion(typeof(byte[]), typeof(String))]
    public class EncodedToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            byte[] bytes = value as byte[];
            if (bytes == null)
                return string.Empty;
            else
                return Encoding.UTF8.GetString(bytes);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string strByte = value as string;
            return Encoding.UTF8.GetBytes(strByte);
        }
    }
}
